package com.platform.controller.backend;

import com.platform.base.BaseController;
import com.platform.common.Const;
import com.platform.common.ServerResponse;
import com.platform.pojo.RolePermission;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 角色操作权限
 */
@RestController
@RequestMapping("/rolePermissionController/")
@CrossOrigin(origins = Const.REQUESTURL,maxAge = 3600,allowCredentials = "true")
public class RolePermissionController extends BaseController {


    @PostMapping(value = "add.do")
    public ServerResponse<String> addRolePermission(Map param){
        return iRolePermissionService.insert(param);
    }

    @PostMapping(value = "del.do")
    public ServerResponse<String> del(Integer id){
       return iRolePermissionService.del(id);
    }

    @GetMapping(value = "selectByParam.do")
    public ServerResponse<List<Integer>> selectByParam(String roleCode){
        return iRolePermissionService.selectByParam(roleCode);
    }

    @PostMapping(value = "update.do")
    public ServerResponse<String> update(RolePermission rolePermission){
        return iRolePermissionService.update(rolePermission);
    }

    @GetMapping(value = "selectAllPermission.do")
    public ServerResponse<List<Map>> selectAllPermission(String roleCode){
        return iRolePermissionService.selectAllPermission(roleCode);
    }


    @PostMapping(value = "addRolePermission.do")
    public ServerResponse<String> addRolePermission(@RequestParam(value = "roleCode") String roleCode,
                                                    @RequestParam(value = "perIdArr") String perIdArr){
        return iRolePermissionService.addRolePermission(roleCode,perIdArr);
    }
}
